"""
化气格
"""

def hua_tu(mp):
    """
    化土格
    """
    cond1_1 = set(mp.sizhu[2][0].gan.name+mp.sizhu[1][0].gan.name) == set('甲己')
    cond1_2 = set(mp.sizhu[2][0].gan.name+mp.sizhu[3][0].gan.name) == set('甲己')
    cond = cond1_1 or cond1_2
    cond = cond and mp.yueling.cell_name() in '辰戌丑未'
    mu_ct = sum([sum([1 if cell.wuxing() == '木' else 0 for cell in zhu]) for zhu in mp.sizhu])
    return cond and mu_ct == 1  # 只有一个甲木，已经被化去


def hua_jin(mp):
    """
    化金格
    """
    cond1_1 = set(mp.sizhu[2][0].gan.name+mp.sizhu[1][0].gan.name) == set('乙庚')
    cond1_2 = set(mp.sizhu[2][0].gan.name+mp.sizhu[3][0].gan.name) == set('乙庚')
    cond = cond1_1 or cond1_2
    cond = cond and mp.yueling.cell_name() in '已酉丑申'
    mu_ct = sum([sum([1 if cell != mp.yueling and cell.wuxing() == '火' else 0 for cell in zhu]) for zhu in mp.sizhu])
    return cond and mu_ct == 0  # 不见火


def hua_shui(mp):
    """
    化水格
    """
    cond1_1 = set(mp.sizhu[2][0].gan.name+mp.sizhu[1][0].gan.name) == set('丙辛')
    cond1_2 = set(mp.sizhu[2][0].gan.name+mp.sizhu[3][0].gan.name) == set('丙辛')
    cond = cond1_1 or cond1_2
    cond = cond and mp.yueling.cell_name() in '申子辰亥'
    mu_ct = sum([sum([1 if cell != mp.yueling and cell.wuxing() == '土' else 0 for cell in zhu]) for zhu in mp.sizhu])
    return cond and mu_ct == 0  # 不见火


def hua_mu(mp):
    """
    化木格
    """
    cond1_1 = set(mp.sizhu[2][0].gan.name+mp.sizhu[1][0].gan.name) == set('丙辛')
    cond1_2 = set(mp.sizhu[2][0].gan.name+mp.sizhu[3][0].gan.name) == set('丙辛')
    cond = cond1_1 or cond1_2
    cond = cond and mp.yueling.cell_name() in '亥卯未寅'
    mu_ct = sum([sum([1 if cell != mp.yueling and cell.wuxing() == '金' else 0 for cell in zhu]) for zhu in mp.sizhu])
    return cond and mu_ct == 1  # 只有一个辛金


def hua_huo(mp):
    """
    化火格
    """
    cond1_1 = set(mp.sizhu[2][0].gan.name+mp.sizhu[1][0].gan.name) == set('戊癸')
    cond1_2 = set(mp.sizhu[2][0].gan.name+mp.sizhu[3][0].gan.name) == set('戊癸')
    cond = cond1_1 or cond1_2
    cond = cond and mp.yueling.cell_name() in '寅午戌巳'
    mu_ct = sum([sum([1 if cell != mp.yueling and cell.wuxing() == '水' else 0 for cell in zhu]) for zhu in mp.sizhu])
    return cond and mu_ct == 0  # 不见水
